package com.spice.im.jspeex.voice;

import java.io.FileInputStream;
import java.io.FileOutputStream;

import org.xiph.speex.SpeexDecoder;

public class JSDecode {
//	public static final int SAMPLE_RATE = 16000;
//	public static final int CHANNELS = 1;
//	public static final int SPEEX_MODE = 1;
//	public static final int SPEEX_QUALITY = 8;
//	private SpeexDecoder mDecoder;
//	public void initEncoder() {
//		mDecoder = new SpeexDecoder();
//		mDecoder.init(SPEEX_MODE, SAMPLE_RATE, CHANNELS, true);
//	}
//	public void spx2raw(String inFileName, String outFileName) {
//        FileInputStream inAccessFile = null;
//        FileOutputStream fileOutputStream = null;
//        try {
//            inAccessFile = new FileInputStream(inFileName);
//            fileOutputStream = new FileOutputStream(outFileName);
//            byte[] inbyte = new byte[20];
//            short[] decoded = new short[160];
//            int readsize = 0;
//            int readedtotal = 0;
//            int decsize = 0;
//            int decodetotal = 0;
//            while ((readsize = inAccessFile.read(inbyte, 0, 20)) != -1) {
//                readedtotal = readedtotal + readsize;
//                decsize = speex.decode(inbyte, decoded, readsize);
//                decsize = mDecoder.getProcessedData(arg0, arg1);
//                fileOutputStream.write(shortArray2ByteArray(decoded), 0, decsize*2);
//                decodetotal = decodetotal + decsize;
//                Log.e("test", "readsize " + readsize + "\n readedtotal" + readedtotal + "\n decsize" + decsize + "\n decodetotal" + decodetotal);
//            }
//            while(true){
//            	mDecoder.getProcessedData(arg0, arg1);
//            }
//            fileOutputStream.close();
//            inAccessFile.close();
//        } catch (Exception e) {
//            Log.e("test", e.toString());
//        }
//    }

}
